package server;

public class Journal {
	private int division, journal;
	private String assNurse, assDoctor, pNbr;
	
	/**Creates a Journal-object for easier use in the DatabaseGuard
	 * @param journal the journal number
	 * @param division the associated division of the journal
	 * @param assNurse 
	 * @param assDoctor
	 * @param pNbr
	 */
	public Journal(int journal, int division, 
			String assNurse, String assDoctor, String pNbr) {
		this.journal = journal;
		this.division = division;
		this.assNurse = assNurse;
		this.assDoctor = assDoctor;
		this.pNbr = pNbr;
	}
	
	/**
	 * A method that retrieves a specified journals journal number. 
	 * @return Returns the journal number
	 */
	public int getJournalNbr() {
		return journal;
	}
	
	/**
	 * Compares the division entry in the journal with the doctors/nurses division. 
	 * @param otherDiv The doctors/nurses division.
	 * @return Returns true if the compared division is the same, otherwise false. 
	 */
	public boolean atDivision(int otherDiv) {
		return division == otherDiv;
	}
	
	/**
	 * Compares the doctor/nurse assigned to a journal with the doctor/nurse trying to access the 
	 * journal.
	 * @param otherNurse The doctor/nurse trying to access the journal
	 * @return True if the compared doctor/nurse is the same as the one who is assigned to 
	 * the journal, otherwise false.  
	 */
	public boolean isNurse(String otherNurse) {
		return assNurse.equals(otherNurse);
	}
	
	
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return journal + " " + pNbr + " " + division + " " + assDoctor + " " + assNurse;
	}
}
